{
const circle_pos_data_clone = JSON.parse(JSON.stringify(circle_position_data));
circle_pos_data_clone.forEach(function(d, i) { d.id = i;});
circle_pos_data_clone.forEach(function(d, i) { d.size = 5;});
const svgContainer = d3.create('svg')
.attr('width', 200)
.attr('height', 200)
.style('background-color', 'whitesmoke');
const circleGroups = svgContainer.selectAll('circle')
.data(circle_pos_data_clone)
.join('g')
circleGroups.append('circle')
.attr('class', 'greenCircle')
.attr("id", function(d) { return "circle_green" + d.id; })
.attr('r', )
.attr('cx', )
.attr('cy', )
.attr('fill', )
.call(d3.drag()
.subject(function(event,d) { return {x: event.x, y: event.y}; })
.on('start',resizeDragStarted)
.on('drag',resizeDragged)
.on('end',resizeDragEnded)
)
circleGroups.append('circle')
.attr('class', 'blueCircle')
.attr("id", function(d) { return "circle_blue" + d.id; })
.attr('r', /* fill in */) // Use d.size to set size attr.
.attr('cx', /* fill in */)
.attr('cy', /* fill in */)
.attr('fill', /* fill in */)
.call(d3.drag()
.subject(function(event,d) { return {x: xScale(d.x), y: yScale(d.y)}; })
.on('start',dragStarted)
.on('drag',dragged)
.on('end',dragEnded)
)
//Callbacks for the resizeDrag
function resizeDragStarted(event, d) {
//Add blue stroke to outter edge of green circle
}
function resizeDragged(event, d) {
//Compute distance between event.x, event.y and d.x,d.y in pixel space.
//Then set distance as the new radius of the blue circles and set this distance + 3 as the radius
// of the green circles
const distFromCircleCenter = /* fill in */
d.size = distFromCircleCenter;
d3.select(/*select green circles*/)
.attr("r", /* fill in */);
d3.select(/*select corresponding blue circles using id attr.*/)
.attr("r", /* fill in */)
}
function resizeDragEnded(event, d) {
//Remove blue stroke from outter edge of green circle
}
// Callback functions for the movement drag
function dragStarted(event, d) {
//Add red stroke to outter edge of green circle
}
function dragged(event, d) {
// Copy code we used earlier for translating the circles
}
function dragEnded(event, d) {
//Remove red stroke from outter edge of green circle
}
return svgContainer.node();
}